<template>
    <!--ASN明细-->
    <div id="AsnDetails">
        <v-details :detailData="data.detailData" :inputConfig="inputConfig" :rules="rules" @pop="setdata" ref="input"></v-details>
    </div>
</template>

<script>

    import details from 'commons/Detail'
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        name: "AsnDetails",
        mixins: [baseMixin],
        props: {
            data: {
                type: Object
            }
        },
        data() {
            return {
                rules: {
                    charge_code: [
                        {required: true, trigger: 'blur'},
                    ],
                    rate_uom: [
                        {required: true, trigger: 'blur'},
                    ],
                    from_break: [
                        {required: true, trigger: 'blur'},
                    ],
                    to_break: [
                        {required: true, trigger: 'blur'},
                    ],
                    break_uom: [
                        {required: true, trigger: 'blur'},
                    ],
                    charge_rate: [
                        {required: true, trigger: 'blur'},
                    ]
                },
            }
        },
        computed: {
            inputConfig() {
                return [
                    [
                        {
                            type: "select",
                            label: this.$t('bill.chargeCode'),
                            props: "charge_code",
                            options: this.getOptions("queryChargeAcctDetailCode")
                        },
                        {
                            type: "select",
                            label: "费率计量单位",
                            props: "rate_uom",
                            options: this.getOptions("queryRateGroupDetailCode")
                        },
                        {
                            type: "select",
                            label: "是否按段分离",
                            props: "separate_by_break",
                            options: [
                                {code: 1, description: this.$t('code.yes')},
                                {code: 0, description: this.$t('code.no')}
                            ]
                        }
                    ],
                    [
                        {
                            type: "input",
                            label: "分段自",
                            props: "from_break"
                        },
                        {
                            type: "input",
                            label: "分段至",
                            props: "to_break",
                        },
                        {
                            type: "select",
                            label: "分段计量单位",
                            props: "break_uom",
                            options: this.getOptions("queryRateGroupDetailCode")
                        }
                    ],
                    [
                        {
                            type: "input",
                            label: this.$t('bill.chargeRate'),
                            props: "charge_rate"
                        },
                        {
                            type: "input",
                            label: "最小值",
                            props: "min_charge"
                        },
                        {
                            type: "input",
                            label: "成本",
                            props: "charge_cost"
                        }
                    ]
                ]
            }
        },
        methods: {
            setdata(data, id, close, listId) {
                if (listId == "1" && id == "1") {
                    this.data.detailData.cr_corp = data.corp_code;
                } else if (listId == "1" && id == "2") {
                    this.data.detailData.cr_dept = data.dept_code;
                } else if (listId == "1" && id == "3") {
                    this.data.detailData.cr_acct = data.acct_code;
                }
                close(false);
            }
        },
        mounted() {
        },
        watch: {},
        components: {
            'v-details': details
        }
    }
</script>

<style scoped>

</style>
